package com.jt.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jt.mapper.RightsMapper;
import com.jt.pojo.Rights;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Title
 * @Author Peihan.Zhang
 * @Email zhangpeihan@sjgtw.com
 * @Date 2021/11/8 23:28
 * @Versions 1.0
 */
@Service
public class RightsServiceImpl  implements  RightsService {

    @Autowired
    private RightsMapper rightsMapper;
    @Override
    public List<Rights> findList() {
        QueryWrapper<Rights> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("parent_id", 0);
        List<Rights> li = rightsMapper.selectList(queryWrapper);
        for ( Rights rightone: li
             ) {
            queryWrapper.clear();
            queryWrapper.eq("parent_id", rightone.getId());
            List<Rights> li2  = rightsMapper.selectList(queryWrapper);
            rightone.setChildren(li2);

        }
            return li;
    }
}
